const firstFile = require('./01es5和es6中的变量')


// console.log(firstFile);
// console.log(firstFile.num);

// console.log(global.b);
// console.log(global.name);
// console.log(global);

// process.on('exit',(code)=>{
//     setTimeout(()=>{
//         console.log('会执行吗？');
//     },0)
//     console.log(`退出码，${code}`);
// })

// console.log('finishing....');

let fn1 = ()=>{
    console.log('普通箭头函数');
}

let fn2 = ()=>'带返回值的函数'

let fn3= ()=>{
    return '带返回值'
}

// let fn4 = (x)=>x*x

// fn1()
// let ret = fn2()
// console.log(ret)

// let ret2 = fn3()
// console.log(ret2);

// let ret3 = fn4(4)
// console.log(ret3);


var temp_value = new Date()
function fn5(){
    console.log(temp_value);
    if(false){
        // var temp_value = 'hahahah'
        let temp_value = 'hahahah'
    }
}

fn5()

// 全局变量2个
// 全局对象3个
// 函数
// 作用域
// 全局函数2个

// let timer1 = setTimeout(()=>{
//     console.log('setTimeout');
// },30)

// let timer2 = setInterval(()=>{
//     console.log('setInterval');
// },1000)

// clearInterval(timer2)

let endTime = new Date('2020/10/10 23:59:59')

// setInterval(()=>{
//     endTime = new Date(endTime.getTime()-1000)
//     console.log(endTime.toLocaleString());
// },1000)

let names = ['云飞扬','令狐冲','晓峰','郭靖','欧阳锋']

function getName(){
    let random =  Math.floor(Math.random()*names.length)
    // let name = names[random]
    let name = names.splice(random,1)
    return name
}

timer = setInterval(()=>{
    let temp = getName()
    if(temp.length>0){
        console.log(temp[0]);
    }else{
        clearInterval(timer)
    }  
},1000)

